package com.alibaba.csp.sentinel.dashboard.config;

import com.alibaba.csp.sentinel.dashboard.rule.DynamicRuleHandler;
import com.alibaba.csp.sentinel.dashboard.rule.nacos.NacosServer;
import com.alibaba.nacos.api.config.ConfigService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * 动态规则处理器自动配置
 *
 * @author slf
 * @since 2024/4/15 21:12
 **/
@Configuration
public class DynamicAutoConfig {
  @Bean
  @ConditionalOnMissingBean(DynamicRuleHandler.class)
  @ConditionalOnClass(ConfigService.class)
  public DynamicRuleHandler dynamicRuleHandler() {
    return new NacosServer();
  }
}
